/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.java.edu.cg1.exercises.introduction;

import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Cylinder;
import com.sun.j3d.utils.geometry.Sphere;
import javax.media.j3d.Group;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Vector3d;


public class Superman {
    
    //Hauptgruppe bzw das "gesamte" SupermanObjekt
    private Group maingroup;
    //Rechter Arm Gruppe wird für die Winkanimation benötigt
    private TransformGroup rightArmGroup;
    
    public Superman(double x, double y, double z){
    maingroup = createSuperman(x, y, z);
    
    }
    /**
     * Erstellung des SupermanObjekts im Koordinatensystem. Superman hat: Kopf,Torso,2 Arme, 2 Beine und ein Cape
     * @param x: X Koordinate
     * @param y: Y Koordinate
     * @param z: Z Koordinate
     * @return Die gesamtgruppe des Superman
     */
     private Group createSuperman(double x, double y, double z) {
    	Cylinder torso = new Cylinder(0.075f, 0.3f);
    	AppearanceHelper.setColor(torso, new Color3f(0.33f, 0.66f, 1f));
    	Transform3D scaleTorso = new Transform3D();
    	scaleTorso.rotX(Math.toRadians(90));
    	scaleTorso.setTranslation(new Vector3d(x, y, z));
    	TransformGroup torsoGroup = new TransformGroup(scaleTorso);
    	torsoGroup.addChild(torso);
    	
    	Cylinder leftLeg = new Cylinder(0.025f, 0.2f);
    	AppearanceHelper.setColor(leftLeg, new Color3f(0.33f, 0.66f, 1f));
    	Transform3D scaleleftLeg = new Transform3D();
    	scaleleftLeg.rotX(Math.toRadians(90));
    	scaleleftLeg.setTranslation(new Vector3d(x, y+0.049, z - 0.2));
    	TransformGroup leftLegGroup = new TransformGroup(scaleleftLeg);
    	leftLegGroup.addChild(leftLeg);
    	
    	Cylinder rightLeg = new Cylinder(0.025f, 0.2f);
    	AppearanceHelper.setColor(rightLeg, new Color3f(0.33f, 0.66f, 1f));
    	Transform3D scalerightLeg = new Transform3D();
    	scalerightLeg.rotX(Math.toRadians(90));
    	scalerightLeg.setTranslation(new Vector3d(x, y-0.049, z - 0.2));
    	TransformGroup rightLegGroup = new TransformGroup(scalerightLeg);
    	rightLegGroup.addChild(rightLeg);
    	
    	Cylinder rightArm = new Cylinder(0.025f, 0.2f);
    	AppearanceHelper.setColor(rightArm, new Color3f(0.33f, 0.66f, 1f));
    	Transform3D scalerightArm = new Transform3D();
    	scalerightArm.rotX(Math.toRadians(90));
    	scalerightArm.setTranslation(new Vector3d(x, y -0.1, z+ 0.2));
    	rightArmGroup = new TransformGroup(scalerightArm);
    	rightArmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    	rightArmGroup.addChild(rightArm);
    	
    	Cylinder leftArm = new Cylinder(0.025f, 0.2f);
    	AppearanceHelper.setColor(leftArm, new Color3f(0.33f, 0.66f, 1f));
    	Transform3D scaleleftArm = new Transform3D();
    	scaleleftArm.rotX(Math.toRadians(90));
    	scaleleftArm.setTranslation(new Vector3d(x, y +0.1, z+ 0.2));
    	TransformGroup leftArmGroup = new TransformGroup(scaleleftArm);
    	leftArmGroup.addChild(leftArm);
    	
    	Sphere head = new Sphere(0.075f);
    	AppearanceHelper.setColor(head, new Color3f(1f, 0.8f, 0.8f));
    	Transform3D scaleHead = new Transform3D();
    	scaleHead.rotX(Math.toRadians(90));
    	scaleHead.setTranslation(new Vector3d(x, y , z+ 0.220));
    	TransformGroup headGroup = new TransformGroup(scaleHead);
    	headGroup.addChild(head);
    	
    	Box cape = new Box();
    	AppearanceHelper.setColor(cape, new Color3f(1f, 0f, 0f));
    	Transform3D scaleCape = new Transform3D();
    	scaleCape.rotY(Math.toRadians(10));
    	scaleCape.setScale(new Vector3d(0.001, 0.1, 0.2));
    	scaleCape.setTranslation(new Vector3d(x-0.10, y, z));
    	TransformGroup capeGroup = new TransformGroup(scaleCape);
    	capeGroup.addChild(cape);
    	
    	Group group = new Group();
    	group.addChild(torsoGroup);
    	group.addChild(leftLegGroup);
    	group.addChild(rightLegGroup);
    	group.addChild(rightArmGroup);
    	group.addChild(leftArmGroup);
    	group.addChild(headGroup);
    	group.addChild(capeGroup);
    	
    	return group;
    }
     
     public Group getMainGroup(){
         return maingroup;
     }
     
     public TransformGroup getRightArmGroup(){
         return rightArmGroup;
     }
}
